package Pattern.TemplatePattern.Program.program3;

public abstract class Game {
    abstract void initialize();
    abstract void startPlay();
    abstract void endPlay();
    //Template method
    public final void play() {
        loadAssets();
        initialize();
        startPlay();
        if (addNewGameCharacter()) {
            addNewCharacterToTheGame();
        }
        endPlay();
    }

    //Hooked on Template Method
    protected abstract void addNewCharacterToTheGame();
    void loadAssets() {
        System.out.println("Loading Game Assets!");//加载游戏资源
    }
    boolean addNewGameCharacter() {
        return true;
    }
}

